package day06_exception_collection.com.itheima.d1_exception;

public class Demo2_Exception {
    public static void main(String[] args) {
        System.out.println("开始。。。");

        try {
//            System.out.println("divide(10, 2) = " + divide(10, 2));
            System.out.println("divide(10, 2) = " + divide(10, 0));
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println("程序出现异常，请稍后再试");
        }


        System.out.println("结束。。。");
    }

    public static int divide(int a,int b){
        if (b == 0){
            System.out.println("除数不能为0");
            throw new RuntimeException("/ by 0");
        }
        int c = a / b;
        return c;
    }
}
